import gtk.gdk
import StringIO
from gtk import *
from xml.sax.saxutils import escape
from os.path import basename
from urllib2 import url2pathname

THUMBNAILS_SIZE = 92
COVER = 0
KEY = 1
VALUE = 2
ID = 3
SEPARATOR = 4
BACKGROUND_COLOR = 5

def build_medialib(mlib):
    model = TreeStore(gtk.gdk.Pixbuf, str)
    treeview = mlib.get_widget("iconview1")
    treeview.set_model(model)

def build_tracklisting(mlib):
    model = ListStore(int, str, str)
    treeview = mlib.get_widget("trackview")
    treeview.set_model(model)
    title_col = TreeViewColumn("title", CellRendererText(), text = 1)
    artist_col = TreeViewColumn("artist", CellRendererText(), text = 2)
    treeview.append_column(title_col)
    treeview.append_column(artist_col)
    selection = treeview.get_selection()
    selection.set_mode(SELECTION_MULTIPLE)
    return treeview

def mark(artist, album):
    return "\n".join([artist, "<i>" + album + "</i>"])

def get_info(markup):
    artist, album = markup.split("\n")
    return artist, album
